package com.shisan.tingshu.account.rpc;

import com.shisan.tingshu.account.service.UserAccountService;
import com.shisan.tingshu.common.result.Result;
import com.shisan.tingshu.model.account.RechargeInfo;
import com.shisan.tingshu.vo.account.AccountLockResultVo;
import com.shisan.tingshu.vo.account.AccountLockVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/inner/accountinfo")
public class UserAccountRpcController {

    @Autowired
    private UserAccountService userAccountService;

    /**
     * 查询并锁定用户余额
     * @param accountLockVo
     * @return
     */
    @PostMapping("/checkAndLockAmount")
    Result<AccountLockResultVo> checkAndLockAmount(@RequestBody AccountLockVo accountLockVo) {

        return userAccountService.checkAndLockAmount(accountLockVo);
    }

    /**
     * 根据订单号查询充值信息
     * @param orderNo
     * @param userId
     * @return
     */
    @PostMapping("/getRechargeInfoByOrderNo/{orderNo}/{userId}")
    Result<RechargeInfo> getRechargeInfoByOrderNo(@PathVariable(value = "orderNo") String orderNo, @PathVariable(value = "userId") Long userId) {

        RechargeInfo rechargeInfo = userAccountService.getRechargeInfoByOrderNo(orderNo, userId);
        return Result.ok(rechargeInfo);
    }
}
